package com.viphuli.app.tool.adapter;

import java.util.List;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import butterknife.Bind;
import butterknife.ButterKnife;

import com.offroader.utils.ViewUtils;
import com.viphuli.app.tool.R;
import com.viphuli.app.tool.bean.part.HolidayHomeLeave;
import com.viphuli.app.tool.common.MyApp;

public class HolidayHomeLeaveAdapter extends BaseAdapter {
	
	private List<HolidayHomeLeave> list;

	public HolidayHomeLeaveAdapter(List<HolidayHomeLeave> list) {
		this.list = list;
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int index) {
		return list.get(index);
	}

	@Override
	public long getItemId(int index) {
		return index;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		ViewHolder holder = null;

		if (convertView == null || convertView.getTag() == null) {
			convertView = ViewUtils.inflateView(MyApp.getInstance(), R.layout.list_item_holiday_leave_day);
			holder = new ViewHolder(convertView);
			convertView.setTag(holder);

		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		HolidayHomeLeave bean = list.get(position);
		
		holder.name.setText(bean.getUserName());
		holder.leave.setText(bean.getLeaveTime());
		holder.leaveDay.setText(bean.getLeaveDay());
		
		return convertView;
	}


	protected class ViewHolder {
		
		@Bind(R.id.id_holiday_user_name)
		TextView name;
		
		@Bind(R.id.id_holiday_leave)
		TextView leave;
		
		@Bind(R.id.id_holiday_leave_day)
		TextView leaveDay;


		public ViewHolder(View view) {
			ButterKnife.bind(this, view);
		}
	}

}
